#include "tracexportprojectselectionpage.h"
#include "tracexportprojectselectwidget.h"
#include "tracvalidationpage.h"
#include "tracsettings.h"

#include <QtGui/QVBoxLayout>
#include <QtGui/QTextEdit>
#include <QDebug>

namespace Trac {
namespace Internal {

TracExportProjectSelectionPage::TracExportProjectSelectionPage(TracValidationPage *validationPage,
                                                               QWidget *parent) :
    QWizardPage(parent),
    m_validationPage(validationPage),
    m_widget(new TracExportProjectSelectWidget())
{
    connect(m_widget, SIGNAL(validChanged(bool)), this, SIGNAL(completeChanged()));
    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(m_widget);
    setLayout(layout);
    setTitle(tr("Select project"));
    setSubTitle(tr("Select a local project to export"));
}

TracExportProjectSelectionPage::~TracExportProjectSelectionPage()
{

}

void TracExportProjectSelectionPage::initializePage()
{
    if(m_widget->connectionUrl() != TracSettings::instance()->hostName()) {
        m_widget->initialize();
        m_widget->requestProjects();
    }
}

bool TracExportProjectSelectionPage::isComplete() const
{
     return m_widget->isValid();
}


} // namespace Internal
} // namespace Trac

